package com.csun.cmny.provider.web.rpc;

import com.csun.cmny.provider.model.domain.OmcExpenseItem;
import com.csun.cmny.provider.model.domain.OmcExpenseType;
import com.csun.cmny.provider.model.domain.OmcExpenseTypeModelCode;
import com.csun.cmny.provider.service.OmcExpenseFeignApi;
import com.csun.cmny.provider.service.OmcExpenseItemService;
import com.csun.cmny.provider.service.OmcExpenseTypeModelCodeService;
import com.csun.cmny.provider.service.OmcExpenseTypeService;
import com.csun.cmny.util.wrapper.WrapMapper;
import com.csun.cmny.util.wrapper.Wrapper;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2019-12-10 19:56
 * @Description:
 */
@RestController
public class OmcExpenseFeignClient implements OmcExpenseFeignApi {

    @Resource
    private OmcExpenseTypeService omcExpenseTypeService;
    @Resource
    private OmcExpenseTypeModelCodeService omcExpenseTypeModelCodeService;
    @Resource
    private OmcExpenseItemService omcExpenseItemService;

    @Override
    public Wrapper saveOmcExpenseType(@RequestBody OmcExpenseType omcExpenseType) {

        omcExpenseTypeService.save(omcExpenseType);

        return WrapMapper.ok(omcExpenseType.getId());
    }

    @Override
    public Wrapper<Long> saveOmcExpenseTypeModelCode(@RequestBody OmcExpenseTypeModelCode omcExpenseTypeModelCode) {

        omcExpenseTypeModelCodeService.save(omcExpenseTypeModelCode);

        return WrapMapper.ok(omcExpenseTypeModelCode.getId());
    }

    @Override
    public Wrapper<Long> saveOmcExpenseItem(@RequestBody OmcExpenseItem omcExpenseItem) {

        omcExpenseItemService.save(omcExpenseItem);

        return WrapMapper.ok(omcExpenseItem.getId());
    }
}
